import React from "react";
import { Button,  Select, Modal, Cascader, TreeSelect, Col, Row,Divider, Input, Collapse } from 'antd/lib';
import notification from "@/services/notification";
import {get} from "lodash";
import Uploads from "@/services/uploads";
import Upload from "antd/lib/upload";
import 'antd/dist/antd.less'
import WarningOutlined from "@ant-design/icons/WarningOutlined";
import {DeleteOutlined, UploadOutlined} from '@ant-design/icons';
import Customer from "@/services/customer";
import Enums from "@/services/enums";
import moment from "moment";
import DatePicker from "antd/lib/date-picker";
import locale from 'antd/es/date-picker/locale/zh_CN';
import { currentUser } from "@/services/auth";
import ContractApply from "@/services/contractapply";
import GlobalFunctions from '@/store/globalFunctions';
import { inject, observer } from 'mobx-react';
import { filter } from 'lodash';

const { confirm } = Modal;
const { Panel } = Collapse;

class ChangeTableOld extends React.Component {
  state = {
    kuangjiaxieyivisible: true,
    volumepurchasevisible: false,
    volumepurchasedata:[{id:0,name:"否"}, {id:1,name:"是"}],

    pay_directiondata:[{id:1,name:"付款"},{id:0,name:"收款"},{id:2,name:"非经济"}],
    pricetypedata:[{id:0,name:"总价合同"},
    {id:1,name:"单价合同"},{id:2,name:"费率合同"},{id:3,name:"成本补偿"},{id:4,name:"绩效激励"}],
    infrastructurevisible: false,
    infrastructuredata:[{id:0,name:"否"}, {id:1,name:"是"}],
    zhengcaidata:[{id:0,name:"否"}, {id:1,name:"是"}],
    iskeyandata:[{id:0,name:"否"}, {id:1,name:"是"}],
    iszhaobiaodata:[{id:0,name:"否"}, {id:1,name:"是"}],
    empowersexdata: [{ id: "是", name: "是" }, { id: "否", name: "否" }],
  };

  componentWillMount() {
      
  }
fieldedit(field){
    return true;
}

  disabledDate=(current)=>{

    return true;
  }

  render() {
    console.log('this.props.contractsdata',this.props.contractsdata)
    console.log('this.props.contractsdata',this.props.contractsdata.officialcode)
    return(
      <div>
      <Collapse defaultActiveKey={['1','2','3']} >
       <Panel header="基本" key="1">
       <Row style={{ marginBottom: 5}}>
        <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>
        合同编码:</div></Col>
				  <Col span={6}>
          <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.officialcode}
               disabled ={this.fieldedit("name")}
                placeholder="合同编码"
            />
          </Col>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>合同名称:</div></Col>
				  <Col span={6}>
              <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.name}
               disabled ={this.fieldedit("name")}
                placeholder="合同名称"
              />
				  </Col>
        </Row>
      <Row style={{ marginBottom: 5}}>
        <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>经办部门:</div></Col>
				  <Col span={6}>
              <Select style={{ width: "100%" }}
                    showSearch
                    optionFilterProp="children"
                      value={this.props.contractsdata.departmentid}
                      disabled ={this.fieldedit("departmentid")}>
              {(this.props.departmentdata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
          </Col>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>经办人:</div></Col>
				  <Col span={6}>
              <Select style={{ width:  "100%" }}
                      showSearch
                      optionFilterProp="children"
                      value={this.props.contractsdata.employeeid}
                      disabled ={this.fieldedit("employeeid")}>
              {(this.props.employeedata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>起草日期:</div></Col>
				  <Col span={6}>
            <DatePicker
              locale={locale}
              style={{ width:"100%" }}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.bill_date) ? null : moment(this.props.contractsdata.bill_date)}
              placeholder="日期"
              disabled ={this.fieldedit("bill_date")}
              autoFocus
            />
          </Col>
        </Row>
        <Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>合同类别:</div></Col>
          <Col span={6}>
                  <TreeSelect
                  showSearch
                  disabled ={this.fieldedit("contracttype")}
                  style={{ width:"100%" }}
                  value={this.props.contractsdata.contracttype}
                  dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                  placeholder="请选择"
                  allowClear
                  treeData={this.props.contracttypenewdata}
                />
				  </Col>
        {this.state.infrastructurevisible && (<>
        <Col span={2}><div className="contractseditTitleStyle">备案合同:</div></Col>
				<Col span={6}>
              <Select style={{ width:  "100%" }} value={this.props.contractsdata.infrastructure} 
              disabled ={this.fieldedit("infrastructure")}>
              {(this.state.infrastructuredata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col></>)}
        {this.state.volumepurchasevisible && (<>
          <Col span={2}><div className="contractseditTitleStyle">带量采购:</div></Col>
				<Col span={6}>
              <Select style={{ width:  "100%" }} value={this.props.contractsdata.volumepurchase} 
              disabled ={this.fieldedit("volumepurchase")}>
              {(this.state.volumepurchasedata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col></>)}
          <Col span={2}><div className="contractseditTitleStyle">状态:</div></Col>
				  <Col span={6}>
              <Input
                style={{ width:"100%" }}
                value={"已审核"}
                placeholder="状态"
                disabled="disabled"
              />
				  </Col>
          </Row>
        <Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>合同单位:</div></Col>
				  <Col span={6}>
              <Select style={{ width:  "100%" }}
              value={this.props.contractsdata.party_aid}
              showSearch
	            optionFilterProp="children"
              disabled ={this.fieldedit("party_aid")}>
              {(this.props.customerdata || []).map(item => (
                <Select.Option value={item.id}>{item.strcustomername}</Select.Option>
              ))}
            </Select>
          </Col>
         <Col span={2}><div className="contractseditTitleStyle">第三方:</div></Col>
				 <Col span={6}>
           <Select style={{ width:  "100%" }}  value={this.props.contractsdata.party_bid} 
           showSearch
	         optionFilterProp="children"
           disabled ={this.fieldedit("party_bid")}>
            {this.props.customerdata.map(item => (
             <Select.Option key={item.id} value={item.id}>{item.strcustomername}</Select.Option>
            ))}
           </Select>
			   </Col>
         {this.state.kuangjiaxieyivisible && (<>
        <Col span={2}><div className="contractseditTitleStyle">收付款类型:</div></Col>
        <Col span={6}>
              <Select style={{ width:  "100%" }} value={this.props.contractsdata.pay_direction} 
              disabled ={this.fieldedit("pay_direction")}>
              {(this.state.pay_directiondata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col></>)}
        </Row>
        {this.state.kuangjiaxieyivisible && (<Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>合同类型</div></Col>
				  <Col span={6}>
              <Select style={{ width:  "100%" }} value={this.props.contractsdata.pricetype} 
              disabled ={this.fieldedit("pricetype")}>
              {(this.state.pricetypedata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>
          { this.props.contractsdata.pricetype===0 ? "金额(¥)":"预算金额(¥)"}:</div></Col>
				  <Col span={6}>
              <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.amount}
                placeholder="金额(¥)"
                onkeyup="this.value=this.value.replace(/\D/g,'')"
                onafterpaste="this.value=this.value.replace(/\D/g,'')"
                type="number"
                disabled ={this.fieldedit("amount")}
              />
				  </Col>
          <Col span={2}><div className="contractseditTitleStyle">金额(大写):</div></Col>
				  <Col span={6}>
              <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.amount_words}
                placeholder="金额(大写)"
                disabled ={true}
              />
				  </Col>
        </Row>)}
        <Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle">签订日期:</div></Col>
				  <Col span={6}>
            <DatePicker
              style={{ width:  "100%" }}
              locale={locale}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.sign_date) ? null : moment(this.props.contractsdata.sign_date)}
              disabled ={true}
              placeholder="签订日期"
            />
				  </Col>
         <Col span={2}><div className="contractseditTitleStyle">开始日期:</div></Col>
				  <Col span={6}>
            <DatePicker
              style={{ width:  "100%" }}
              locale={locale}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.start_date) ? null : moment(this.props.contractsdata.start_date)}
              placeholder="开始日期"
              disabled ={true}
            />
          </Col>
          <Col span={2}><div className="contractseditTitleStyle">终止日期:</div></Col>
				  <Col span={6}>
            <DatePicker
              locale={locale}
              style={{ width:  "100%" }}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.end_date) ? null : moment(this.props.contractsdata.end_date)}
              disabledDate={this.disabledDate}
              placeholder="终止日期"
              disabled ={true}
            />
				  </Col>
        </Row>
        <Row style={{ marginBottom: 5}}>
        {this.state.kuangjiaxieyivisible && (<>
        <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>资金类别:</div></Col>
        <Col span={6}>
              <Select style={{ width:  "100%" }}
                    showSearch
                    mode="multiple"
                    allowClear
                    disabled ={this.fieldedit("amounttype")}
                    optionFilterProp="children"
                      value={this.props.contractsdata.amounttype}
                    >
              {(this.props.amounttypedata || []).map(item => (
                <Select.Option key={item.value} value={item.value}>{item.label}</Select.Option>
              ))}
              </Select>
				  </Col></>)}
          <Col span={2}><div className="contractseditTitleStyle">是否科研:</div></Col>
            <Col span={6}>
                <Select style={{ width:  "100%" }} value={this.props.contractsdata.iskeyan} 
                disabled ={this.fieldedit("iskeyan")}>
                {(this.state.iskeyandata || []).map(item => (
                  <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
                ))}
                </Select>
            </Col>
        <Col span={2}><div className="contractseditTitleStyle">备案号:</div></Col>
        <Col span={6}>
              <Input
                style={{ width:  "100%" }}
                value={this.props.contractsdata.recordcode}
                placeholder="null"
                disabled ={true}
                autoFocus
              />
          </Col>
        </Row>
        <Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{ color: '#f81d22', fontSize: 12 }}>*</span>是否公开招标:</div></Col>
            <Col span={6}>
                <Select style={{ width:  "100%" }} value={this.props.contractsdata.iszhaobiao} 
                disabled ={this.fieldedit("iszhaobiao")}>
                {(this.state.iszhaobiaodata || []).map(item => (
                  <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
                ))}
                </Select>
            </Col>
            <Col span={2}><div className="contractseditTitleStyle">是否集采:</div></Col>
        <Col span={6}>
              <Select style={{ width:  "100%" }} value={this.props.contractsdata.zhengcai} 
              disabled ={this.fieldedit("zhengcai")}>
              {(this.state.zhengcaidata || []).map(item => (
                <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
              ))}
              </Select>
				  </Col>
         <Col span={2}><div className="contractseditTitleStyle">预算编号:</div></Col>
         <Col span={6}>
            <Select style={{ width:  "100%" }}
                      showSearch
                      optionFilterProp="children"
                      value={this.props.contractsdata.budgetcode}
                      disabled ={this.fieldedit("budgetcode")}>
              {(this.props.yusuandata || []).map(item => (
                <Select.Option key={item.code} value={item.code}>{item.name}</Select.Option>
              ))}
              </Select>
          </Col>
        </Row>
        <Row style={{ marginBottom: 5 }}>
            <Col span={2}><div className="contractseditTitleStyle"><span style={{ color: '#f81d22', fontSize: 12 }}>*</span>是否授权委托:</div></Col>
              <Col span={6}>
                <Select style={{ width: "100%" }} value={this.props.contractsdata.empowersex}
                  disabled={this.fieldedit("empowersex")}>
                  {(this.state.empowersexdata || []).map(item => (
                    <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>
                  ))}
                </Select>
              </Col>
              {this.props.contractsdata.empowersex==="是" && (<>
              <Col span={2}><div className="contractseditTitleStyle"><span style={{ color: '#f81d22', fontSize: 12 }}>*</span>授权代理人:</div></Col>
              <Col span={6}>
              <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.empowerperson}
               disabled ={this.fieldedit("empowerperson")}
                placeholder="授权代理人"
              />
              </Col>
              <Col span={2}><div className="contractseditTitleStyle"><span style={{ color: '#f81d22', fontSize: 12 }}>*</span>代理人职务:</div></Col>
              <Col span={6}>
              <Input
              style={{ width:  "100%" }}
                value={this.props.contractsdata.empowerduties}
               disabled ={this.fieldedit("empowerduties")}
                placeholder="代理人职务"
              />
              </Col></>)}
            </Row>
      </Panel>
      <Panel header="提醒" key="2">
      <Row style={{ marginBottom: 5}}>
        <Col span={2}><div className="contractseditTitleStyle">审核提醒:</div></Col>
				 <Col span={6}>
             <textarea
               rows="3" cols="50"
               textAlignVertical="top"
               height="100px"
               value={this.props.contractsdata.warn_check}
                placeholder="审核提醒"
               disabled ={this.fieldedit("warn_check")}
              />
				  </Col>
          <Col span={2}><div className="contractseditTitleStyle">提醒内容:</div></Col>
          <Col span={6}>
             <textarea
               rows="3" cols="50"
               textAlignVertical="top"
               height="100px"
               value={this.props.contractsdata.warn_message}
                placeholder="提醒内容"
               disabled ={true}
              />
				  </Col>
        </Row>
        <Row style={{ marginBottom: 5}}>
        <Col span={2}><div className="contractseditTitleStyle">审批截止日期:</div></Col>
          <Col span={6}>
            <DatePicker
              locale={locale}
              style={{ width:  "100%" }}
              disabled ={this.fieldedit("warn_checkdate")}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.warn_checkdate) ? null : moment(this.props.contractsdata.warn_checkdate)}
              placeholder="审批截止日期"
            />
          </Col>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>提醒日期:</div></Col>
          <Col span={6}>
            <DatePicker
              locale={locale}
              style={{ width:  "100%" }}
              disabled ={true}
              value={GlobalFunctions.isEmptyobj(this.props.contractsdata.warn_date) ? null : moment(this.props.contractsdata.warn_date)}
              placeholder="提醒日期"
            />
          </Col>
        </Row>
      </Panel>
      <Panel header="其它" key="3">
        <Row style={{ marginBottom: 5}}>
          <Col span={2}><div className="contractseditTitleStyle"><span style={{color:'#f81d22',fontSize:12}}>*</span>重要条款:</div></Col>
          <Col span={6}>
             <textarea
               rows="3" cols="50"
               textAlignVertical="top"
               height="100px"
               value={this.props.contractsdata.message}
                placeholder="重要条款"
               disabled ={this.fieldedit("message")}
              />
				  </Col>
        </Row>
      </Panel>
      </Collapse>
      </div>
    );
  };
}

export default inject('contractChangeStore')(observer(ChangeTableOld));